package com.pet.client.common;

import com.pet.framework.page.ATTPage;
import com.pet.framework.page.Page;
import com.pet.framework.page.PagerFactory;
import com.pet.framework.util.BaseAction;
import com.pet.server.bo.common.UserService;
import com.pet.server.po.Article;
import com.pet.server.po.PetSay;
import com.pet.server.po.RequestInfo;
import com.pet.server.po.UserArticle;
import com.pet.server.po.UserInfo;
import com.pet.server.po.UserTask;
import com.pet.server.po.UserTaskDaily;
import com.pet.system.constants.ATTSystem;

public class UserAction extends BaseAction {

	private UserService userService;
	
	private UserInfo user;
	
	private Integer id;
	
	private RequestInfo requestInfo;
	
	private UserTask userTask;
	
	private UserTaskDaily userTaskDaily;
	
	private UserArticle userArticle;
	
	
	/**
	 * 删除收藏数据
	 * @return
	 */
	public String deleteUserArticle(){
		UserArticle v = userService.getObject(id, UserArticle.class);
		if(null!=v){
			v.setState(ATTSystem.DEV);
			userService.updateObject(v);
		}
		return SUCCESS;
	}
	/**
	 * 删除提问数据
	 * @return
	 */
	public String deleteRequestInfo(){
		RequestInfo v = userService.getObject(id, RequestInfo.class);
		if(null!=v){
			v.setState(ATTSystem.DEV);
			userService.updateObject(v);
		}
		return SUCCESS;
	}
	
	
	/**
	 * 删除每天任务数据
	 * @return
	 */
	public String deleteUserTaskDaily(){
		UserTaskDaily v = userService.getObject(id, UserTaskDaily.class);
		if(null!=v){
			v.setState(ATTSystem.DEV);
			userService.updateObject(v);
		}
		return SUCCESS;
	}
	
	
	
	/**
	 * 删除常规任务数据
	 * @return
	 */
	public String deleteUserTask(){
		UserTask v = userService.getObject(id, UserTask.class);
		if(null!=v){
			v.setState(ATTSystem.DEV);
			userService.updateObject(v);
		}
		return SUCCESS;
	}
	
	
	
	
	/**
	 * 删除用户数据
	 * @return
	 */
	public String deleteUserInfo(){
		UserInfo v = userService.getObject(id, UserInfo.class);
		if(null!=v){
			v.setState(ATTSystem.DEV);
			userService.updateObject(v);
		}
		return SUCCESS;
	}
	
	/**
	 * 用户 常规任务
	 * @return
	 */
	public String searchUserTask(){
		Page page = PagerFactory.createPage();
		userService.searchUserTask(page, userTask);
		setAttr(ATTPage.PAGE_LIST, page);
		return SUCCESS;
	}
	/**
	 * 用户 每天任务
	 * @return
	 */
	public String searchUserTaskDaily(){
		Page page = PagerFactory.createPage();
		userService.searchUserTaskDaily(page, userTaskDaily);
		setAttr(ATTPage.PAGE_LIST, page);
		return SUCCESS;
	}
	
	/**
	 * 用户提问列表（调查）
	 * @return
	 */
	public String queryeOption(){
		
		setAttr("list",userService.queryeOption(id));
		return SUCCESS;
	}
	/**
	 * 用户提问列表（提问）
	 * @return
	 */
	public String queryeAnswerInfo(){
		
		setAttr("list",userService.queryeAnswerInfo(id));
		return SUCCESS;
	}
	
	/**
	 * 用户提问列表
	 * @return
	 */
	public String searchRequestInfo(){
		Page page = PagerFactory.createPage();
		userService.searchRequestInfo(page, requestInfo);
		setAttr(ATTPage.PAGE_LIST, page);
		return SUCCESS;
	}
	/**
	 * 用户列表
	 * @return
	 */
	public String searchUserInfo(){
		Page page = PagerFactory.createPage();
		userService.searchUserInfo(page, user);
		setAttr(ATTPage.PAGE_LIST, page);
		return SUCCESS;
	}
	
	
	/**
	 * 文件收藏
	 * @return
	 */
	public String searchUserArticle(){
		Page page = PagerFactory.createPage();
		userService.searchUserArticle(page, userArticle);
		setAttr(ATTPage.PAGE_LIST, page);
		return SUCCESS;
	}
	
	
	
	public String searchPetInfo(){
		return SUCCESS;
	}
	

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	/**
	 * @return the user
	 */
	public UserInfo getUser() {
		return user;
	}
	/**
	 * @param user the user to set
	 */
	public void setUser(UserInfo user) {
		this.user = user;
	}

	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}
	/**
	 * @return the requestInfo
	 */
	public RequestInfo getRequestInfo() {
		return requestInfo;
	}
	/**
	 * @param requestInfo the requestInfo to set
	 */
	public void setRequestInfo(RequestInfo requestInfo) {
		this.requestInfo = requestInfo;
	}
	
}
